
import '../model/dc_ssdata.dart';

import '../model/station.dart';
import '../model/user.dart';
import 'uidata.dart';
class CacheHelper {

  static void Init() async {
    userList = await User.GetAllList();

    stationList = await Station.GetAllList();
    var sk=await DCSSData.Get();
    UIData.SkData1=sk;
  }

  static List<User> userList=<User>[];
  static List<Station> stationList=<Station>[];
  

  static User GetUser(String userId) {
   
    if(userList.isEmpty){
      Init();
      return null!;
    }
 
    for (var x in userList) {
     // print(x.Guid+","+userId);
      if (x.Guid == userId.toLowerCase()) return x;
    }
    return null!;
  }

  static String getUserName(String userId) {
   
    var a=GetUser(userId);
    return a.Name;
  }


  static List<User> GetUserList() {
    return userList;
  }

  static Station GetStation(String ID) {
    for (var x in stationList) {
      if (x.Guid == ID) return x;
    }
    return null!;
  }


  static Future<List<Station>> GetStationList() async {
    if(stationList==null)
    stationList=await Station.GetAllList();
    return stationList;
  }







}
